﻿using System;
using System.Data;

namespace ReflectionStudio.Core.Events
{
    /// <summary>
    /// Define the message event type and also the log level
    /// </summary>
    public enum MessageEventType
    {
        /// <summary>
        /// Type used for no log but not in messaging system
        /// </summary>
        None = 0,
        /// <summary>
        /// Only in case of exception
        /// </summary>
        Error = 1,
        /// <summary>
        /// Used by all messages
        /// </summary>
        Info = 2,
        /// <summary>
        /// Used by trace messages
        /// </summary>
        Verbose = 3,
        Help = 4
    }

    /// <summary>
    /// Classe used to store message information which are mapped to the log grid
    /// </summary>
    public class MessageInfo
    {
        #region ----------------PROPERTIES----------------

        private MessageEventType _Type = MessageEventType.Info;
        /// <summary>
        /// Type of message = the log level
        /// </summary>
        public MessageEventType Type
        {
            get { return _Type; }
            set { _Type = value; }
        }
        public int ID
        {
            get;
            set;
        }
        private DateTime _When = DateTime.Now;
        /// <summary>
        /// When does this event occurs
        /// </summary>
        public DateTime When
        {
            get { return _When; }
            set { _When = value; }
        }

        private string _Where="";
        /// <summary>
        /// Where it occurs in the code, only used by trace event in verbose mode
        /// </summary>
        public string Where
        {
            get { return _Where; }
            set { _Where = value; }
        }
        private string _What="";
        /// <summary>
        /// Where it occurs in the code, only used by trace event in verbose mode
        /// </summary>
        public string What
        {
            get { return _What; }
            set { _What = value; }
        }
        private string _Details=""; public string Details { get { return _Details; } set { _Details = value; } }
        private string _Sender = ""; public string Sender { get { return _Sender; } set { _Sender = value; } }
        private string _LO = ""; public string LO { get { return _LO; } set { _LO = value; } }
        private string _LB = ""; public string LB { get { return _LB; } set { _LB = value; } }
        private string _LP = ""; public string LP { get { return _LP; } set { _LP = value; } }
        private string _MSGTYPE = ""; public string MSGTYPE { get { return _MSGTYPE; } set { _MSGTYPE = value; } }
        private string _RWKRS = ""; public string RWKRS { get { return _RWKRS; } set { _RWKRS = value; } }
        private string _RWLFD = ""; public string RWLFD { get { return _RWLFD; } set { _RWLFD = value; } }
        private string _RWPOS = ""; public string RWPOS { get { return _RWPOS; } set { _RWPOS = value; } }
        private string _STKNR = ""; public string STKNR { get { return _STKNR; } set { _STKNR = value; } }
        private string _ACTION = ""; public string ACTION { get { return _ACTION; } set { _ACTION = value; } }
        private string _AUFTYP=""; public string AUFTYP { get { return _AUFTYP; } set { _AUFTYP = value; } }
        private string _KRS=""; public string KRS { get { return _KRS; } set { _KRS = value; } }
        private string _LFD=""; public string LFD { get { return _LFD; } set { _LFD = value; } }
        private string _POS=""; public string POS { get { return _POS; } set { _POS = value; } }
        private string _LIEFSCH=""; public string LIEFSCH { get { return _LIEFSCH; } set { _LIEFSCH = value; } }
        private string _BESCHICH=""; public string BESCHICH { get { return _BESCHICH; } set { _BESCHICH = value; } }
        private string _ZUSTAND=""; public string ZUSTAND { get { return _ZUSTAND; } set { _ZUSTAND = value; } }
        private string _ZENSUR=""; public string ZENSUR { get { return _ZENSUR; } set { _ZENSUR = value; } }
        private string _ZENSURKZ=""; public string ZENSURKZ { get { return _ZENSURKZ; } set { _ZENSURKZ = value; } }
        private string _ART=""; public string ART { get { return _ART; } set { _ART = value; } }
        private string _KOLL=""; public string KOLL { get { return _KOLL; } set { _KOLL = value; } }
        private string _VAR=""; public string VAR { get { return _VAR; } set { _VAR = value; } }
        private string _FARBE=""; public string FARBE { get { return _FARBE; } set { _FARBE = value; } }
        private string _WAKZ=""; public string WAKZ { get { return _WAKZ; } set { _WAKZ = value; } }
        private string _DESS=""; public string DESS { get { return _DESS; } set { _DESS = value; } }
        private string _COLORIT=""; public string COLORIT { get { return _COLORIT; } set { _COLORIT = value; } }
        private string _GROE=""; public string GROE { get { return _GROE; } set { _GROE = value; } }
        private string _ORDER=""; public string ORDER { get { return _ORDER; } set { _ORDER = value; } }
        private string _PARTIE=""; public string PARTIE { get { return _PARTIE; } set { _PARTIE = value; } }

        private string _QTY=""; public string QTY { get { return _QTY; } set { _QTY = value; } }
        private DataSet _Set; public DataSet Set { get { return _Set; } set { _Set = value; } }

        private string _P1=""; public string P1 { get { return _P1; } set { _P1 = value; } }
        private string _P2=""; public string P2 { get { return _P2; } set { _P2 = value; } }
        private string _P3=""; public string P3 { get { return _P3; } set { _P3 = value; } }
        private string _P4=""; public string P4 { get { return _P4; } set { _P4 = value; } }
        private string _P5=""; public string P5 { get { return _P5; } set { _P5 = value; } }
        private string _P6=""; public string P6 { get { return _P6; } set { _P6 = value; } }
        private string _P7=""; public string P7 { get { return _P7; } set { _P7 = value; } }
        private string _P8=""; public string P8 { get { return _P8; } set { _P8 = value; } }
        private string _P9=""; public string P9 { get { return _P9; } set { _P9 = value; } }
        private string _P0=""; public string P0 { get { return _P0; } set { _P0 = value; } }
        private string _P11=""; public string P11 { get { return _P11; } set { _P11 = value; } }
        private string _P12=""; public string P12 { get { return _P12; } set { _P12 = value; } }
        private string _P13=""; public string P13 { get { return _P13; } set { _P13 = value; } }
        private string _P14=""; public string P14 { get { return _P14; } set { _P14 = value; } }
        private string _P15=""; public string P15 { get { return _P15; } set { _P15 = value; } }
        private string _P16=""; public string P16 { get { return _P16; } set { _P16 = value; } }
        private string _P17=""; public string P17 { get { return _P17; } set { _P17 = value; } }
        private string _P18=""; public string P18 { get { return _P18; } set { _P18 = value; } }
        private string _P19=""; public string P19 { get { return _P19; } set { _P19 = value; } }
        private string _P10=""; public string P10 { get { return _P10; } set { _P10 = value; } }
        private string _P21=""; public string P21 { get { return _P21; } set { _P21 = value; } }
        private string _P22=""; public string P22 { get { return _P22; } set { _P22 = value; } }
        private string _P23=""; public string P23 { get { return _P23; } set { _P23 = value; } }
        private string _P24=""; public string P24 { get { return _P24; } set { _P24 = value; } }
        private string _P25=""; public string P25 { get { return _P25; } set { _P25 = value; } }
        private string _P26=""; public string P26 { get { return _P26; } set { _P26 = value; } }
        private string _P27=""; public string P27 { get { return _P27; } set { _P27 = value; } }
        private string _P28=""; public string P28 { get { return _P28; } set { _P28 = value; } }
        private string _P29=""; public string P29 { get { return _P29; } set { _P29 = value; } }
        private string _P20=""; public string P20 { get { return _P20; } set { _P20 = value; } }
        #endregion

        #region ----------------CONSTRUCTORS----------------

        /// <summary>
        /// Constructor
        /// </summary>
        public MessageInfo()
        {
            ID = EventDispatcher.Instance.MSGID;
        }
        public MessageInfo(MessageInfo msg)
        {
            ID = EventDispatcher.Instance.MSGID;
            Sender = msg.Sender;
            ORDER = msg.ORDER;
            PARTIE = msg.PARTIE;
            Type = msg.Type;
            Where = msg.Where;
            Details = msg.Details;
            Details = msg.Details;
            Sender = msg.Sender;
            LO = msg.LO;
            LB = msg.LB;
            LP = msg.LP;
            MSGTYPE = msg.MSGTYPE;
            RWKRS = msg.RWKRS;
            RWLFD = msg.RWLFD;
            RWPOS = msg.RWPOS;
            STKNR = msg.STKNR;
            ACTION = msg.ACTION;
            AUFTYP = msg.AUFTYP;
            KRS = msg.KRS;
            LFD = msg.LFD;
            POS = msg.POS;
            LIEFSCH = msg.LIEFSCH;
            BESCHICH = msg.BESCHICH;
            ZUSTAND = msg.ZUSTAND;
            ZENSUR = msg.ZENSUR;
            ZENSURKZ = msg.ZENSURKZ;
            ART = msg.ART;
            KOLL = msg.KOLL;
            VAR = msg.VAR;
            FARBE = msg.FARBE;
            WAKZ = msg.WAKZ;
            DESS = msg.DESS;
            COLORIT = msg.COLORIT;
            GROE = msg.GROE;

            QTY = msg.QTY;
            Set = msg.Set;

            P1 = msg.P1;
            P2 = msg.P2;
            P3 = msg.P3;
            P4 = msg.P4;
            P5 = msg.P5;
        }
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="typ"></param>
        /// <param name="where"></param>
        /// <param name="details"></param>
        public MessageInfo(MessageEventType typ, string where, string details)
        {
            _Type = typ;
            _Where = where;
            _Details = details;
            if(_Where==null)
                _Where="";
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="typ"></param>
        /// <param name="where"></param>
        /// <param name="details"></param>
        public MessageInfo(MessageEventType typ, string what, string where, string details)
        {
            _Type = typ;
            _What = what;
            _Where = where;
            _Details = details;
        }
        #endregion

        #region ----------------OVERRIDES----------------

        /// <summary>
        /// override the method for use in the trace methods
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            switch (_Type)
            {
                case MessageEventType.Error:
                    return string.Format("ERROR: {0}; into:{1}; details:{2};", _When, _Where, _Details);
                case MessageEventType.Info:
                case MessageEventType.Verbose:
                    return string.Format("INFO: {0}; into:{1}; details:{2};", _When, _Where, _Details);
                default:
                    return string.Empty;
            }
        }

        #endregion
    }
}
